package org.lsy.tlais.controller;


import lombok.extern.slf4j.Slf4j;
import org.lsy.tlais.pojo.Emp;
import org.lsy.tlais.pojo.EmpPrame;
import org.lsy.tlais.pojo.PageResult;
import org.lsy.tlais.pojo.Result;
import org.lsy.tlais.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/emps")
public class EmpController {

    @Autowired
    private EmpService empService;

    // 员工分页查询
    @GetMapping
    public Result pageQuery(EmpPrame empPrame) {
        log.info("分页查询：{}", empPrame);
        PageResult<Emp> pageResult = empService.pageQuery(empPrame);
        return Result.success(pageResult);
    }

    //新增员工
    @PostMapping
    public Result insert(@RequestBody Emp emp) {
        log.info("新增员工：{}", emp);
        empService.insert(emp);
        return Result.success();
    }

}
